package com.huangzhao.gulimall.product.web;

import com.huangzhao.gulimall.product.service.SkuInfoService;
import com.huangzhao.gulimall.product.vo.SkuItemVo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Log4j2
@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;

    /**
     *  查询商品详情
     *
     * @return
     */
    @RequestMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model){
        log.info("准备查询" + skuId +"详情");
        SkuItemVo  vo = skuInfoService.item(skuId);
        model.addAttribute("item", vo);
        return "item";
    }
}
